import 'package:hkzf_flutter/dio/general_type.dart';
import 'package:scoped_model/scoped_model.dart';
// 过滤条件组件的状态管理
class FilterBarModel extends Model {
  List<GeneralType> _roomTypeList = [];// 房屋户型
  List<GeneralType> _orientedList = [];// 房屋朝向
  List<GeneralType> floorList = [];// 楼层

  final Set<String> _selectedList = Set<String>();// 选中不可重复的集合

  // 获取数据集Map对象（像属性一样访问，但实际上调用了 get 方法）
  Map<String, List<GeneralType>> get dataList {
    // var result = Map<String, List<GeneralType>>();
    // result['roomTypeList'] = _roomTypeList;
    // result['orientedList'] = _orientedList;
    // result['floorList'] = floorList;
    // return result;
    return {
      'roomTypeList': _roomTypeList,
      'orientedList': _orientedList,
      'floorList': floorList,
    };
  }
  // 设置数据集Map对象（定义一个 设置属性值的方法）
  set dataList(Map<String, List<GeneralType>> data) {
    _roomTypeList = data['roomTypeList']!;
    _orientedList = data['orientedList']!;
    floorList = data['floorList']!;
    // 通知监听者
    notifyListeners();
  }
  //  获取已选数据集
  Set<String> get selectedList {
    return _selectedList;
  }
  // 添加或删除已选集合中数据
  selectedListTroggleItem(String data) {
    if (_selectedList.contains(data)) {
      _selectedList.remove(data);
    } else {
      _selectedList.add(data);
    }
    // 通知监听者
    notifyListeners();
  }
}
